package ua.edu.nuos.jeetraining2012.cms.entity;

import javax.persistence.Column;
import java.io.Serializable;

/**
 * Complex ID class for Students to Quiz Entity.
 *
 * @author Victor N. Ganichev victor.ganichev@gmail.com
 * @version 1.0 Date: 26.05.13 Time: 17:14
 * @since 1.0
 */
public class StudentsToQuizId implements Serializable {

    @Column(name = "student_id")
    private long studentId;

    @Column(name = "quiz_id")
    private long quizId;

    // Default constructor
    public StudentsToQuizId() {}

    // Getters & Setters
    public long getStudentId() {
        return studentId;
    }

    public void setStudentId(long studentId) {
        this.studentId = studentId;
    }

    public long getQuizId() {
        return quizId;
    }

    public void setQuizId(long quizId) {
        this.quizId = quizId;
    }

    // Overrides
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        StudentsToQuizId that = (StudentsToQuizId) o;

        if (quizId != that.quizId) return false;
        if (studentId != that.studentId) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = (int) (studentId ^ (studentId >>> 32));
        result = 31 * result + (int) (quizId ^ (quizId >>> 32));
        return result;
    }
}
